{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">用户优惠券管理</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form layui-form-pane" action="{:url('admin/usercoupon/index')}" method="get">
                    <div class="layui-inline">
                        <label class="layui-form-label">用户名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword_name" value="{$keyword_name}" placeholder="请输入关键词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">用户手机</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword_phone" value="{$keyword_phone}" placeholder="请输入关键词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">购物券名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword_coupon" value="{$keyword_coupon}" placeholder="请输入关键词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                    </div>
                </form>
                <hr>
                <form action="" method="post" class="ajax-form">
                <button type="button" class="layui-btn layui-btn-danger layui-btn-small ajax-action" data-action="{:url('admin/usercoupon/delete')}">删除</button>
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th style="width: 15px;"><input type="checkbox" class="check-all"></th>
                        <th style="width: 30px;">ID</th>
                        <th>用户名称</th>
                        <th>用户手机</th>
                        <th>购物券名称</th>
                        <th>抵消金额</th>
                        <th>购买日期</th>
                        <th>是否过期</th>
                        <th>是否使用</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name="usercoupon_list" item="vo"}
                    <tr>
                        <td><input type="checkbox" name="ids[]" value="{$vo.id}"></td>
                        <td>{$vo.id}</td>
                        {foreach $user_list as $ul}
                            {if $ul.id eq $vo.userID}
                                <td>{$ul.name}</td>
                                <td>{$ul.phone}</td>
                            {/if}
                        {/foreach}
                        <td>{$vo.couponName}</td>
                        <td>{$vo.offsetMoney}</td>
                        <td>{$vo.buyDate}</td>
                        <td>
                            {if $vo.uses==0}
                                <!-- 已使用 -->-----
                            {elseif $vo.uses==1 /}
                                {if  $vo.status==0}
                                    过期
                                {elseif $vo.status==1 /}
                                    未过期
                                {/if}
                            {/if}
                        </td>
                        <td>
                            {if $vo.uses==0}
                                已使用&nbsp;&nbsp;时间:{$vo.usesDate}&nbsp;&nbsp;处理人:{$vo.disposeMan}
                            {elseif $vo.uses==1 /}
                                {if  $vo.status==0}
                                    <!-- 已过期,无法使用 -->-----
                                {elseif $vo.status==1 /}
                                    <a href="{:url('admin/usercoupon/uses',['id'=>$vo['id']])}" class="layui-btn layui-btn-normal layui-btn-mini">使用</a>
                                {/if}
                            {/if}
                        </td>
                        <td>
                            <a href="{:url('admin/usercoupon/delete',['id'=>$vo['id']])}" class="layui-btn layui-btn-danger layui-btn-mini ajax-delete">删除</a>
                        </td>
                        
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                <!--分页-->
                {$usercoupon_list->render()}
                </form>
            </div>
        </div>
    </div>
</div>
{/block}